<%@ Control Language="c#" AutoEventWireup="True" Codebehind="DetailView.ascx.cs" Inherits="SplendidCRM.Campaigns.DetailView" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<script runat="server">
/**********************************************************************************************************************
 * SplendidCRM is a Customer Relationship Management program created by SplendidCRM Software, Inc. 
 * Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved.
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU Affero General Public License as published by the Free Software Foundation, either version 3 
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with this program. 
 * If not, see <http://www.gnu.org/licenses/>. 
 * 
 * You can contact SplendidCRM Software, Inc. at email address support@splendidcrm.com. 
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 
 * the Appropriate Legal Notices must display the following words on all interactive user interfaces: 
 * "Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved."
 *********************************************************************************************************************/
</script>
<div id="divDetailView">
	<%@ Register TagPrefix="SplendidCRM" Tagname="ModuleHeader" Src="~/_controls/ModuleHeader.ascx" %>
	<SplendidCRM:ModuleHeader ID="ctlModuleHeader" Module="Campaigns" EnablePrint="true" HelpName="DetailView" EnableHelp="true" Runat="Server" />

	<asp:Table Width="100%" runat="server">
		<asp:TableRow>
			<asp:TableCell HorizontalAlign="Left">
				<%@ Register TagPrefix="SplendidCRM" Tagname="DynamicButtons" Src="~/_controls/DynamicButtons.ascx" %>
				<SplendidCRM:DynamicButtons ID="ctlDynamicButtons" Visible="<%# !PrintView %>" Runat="Server" />
			</asp:TableCell>
			<asp:TableCell HorizontalAlign="Right" Wrap="false">
				<SplendidCRM:DynamicButtons ID="ctlDynamicLinks" HorizontalAlign="Right" ShowRequired="false" ShowError="false" Visible="<%# !PrintView %>" Runat="Server" />
			</asp:TableCell>
		</asp:TableRow>
	</asp:Table>

	<%@ Register TagPrefix="SplendidCRM" Tagname="DetailNavigation" Src="~/_controls/DetailNavigation.ascx" %>
	<SplendidCRM:DetailNavigation ID="ctlDetailNavigation" Module="<%# m_sMODULE %>" Visible="<%# !PrintView %>" Runat="Server" />

	<asp:HiddenField ID="LAYOUT_DETAIL_VIEW" Runat="server" />
	<table ID="tblMain" class="tabDetailView" runat="server">
	</table>

    <!-- Contact list-->
    <%@ Register TagPrefix="SplendidCRM" Tagname="ListHeader" Src="~/_controls/ListHeader.ascx" %>
    <SplendidCRM:ListHeader Visible="true" Title="Contact list" Runat="Server" />
    <SplendidCRM:SplendidGrid id="grdContactList" Visible="true" AllowPaging="true" AllowSorting="true" EnableViewState="true" runat="server">
		<Columns>
        	<asp:TemplateColumn HeaderText="" ItemStyle-Width="1%">
				<ItemTemplate><%# grdContactList.InputCheckbox(true, ctlCheckAll.FieldName, Sql.ToGuid(Eval("CAMPAIGNS_CONTACT_ID")), ctlCheckAll.SelectedItems)%></ItemTemplate>
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="Name"  SortExpression="LAST_NAME">
				<ItemTemplate>
					<asp:Label Text='<%#Eval("LAST_NAME") %>' runat="server" />
				</ItemTemplate>
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="Mobile Phone"  SortExpression="PHONE_MOBILE">
				<ItemTemplate>
					<asp:Label Text='<%#Eval("PHONE_MOBILE") %>' runat="server" />
				</ItemTemplate>
			</asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Work Phone"  SortExpression="PHONE_WORK">
				<ItemTemplate>
					<asp:Label Text='<%#Eval("PHONE_WORK") %>' runat="server" />
				</ItemTemplate>
			</asp:TemplateColumn>
            <asp:TemplateColumn HeaderText="Assigned to team"  SortExpression="ASSIGN_TO_TEAM">
				<ItemTemplate>
					<asp:Label Text='<%#Eval("ASSIGN_TO_TEAM") %>' runat="server" />
				</ItemTemplate>
			</asp:TemplateColumn>
		</Columns>
	</SplendidCRM:SplendidGrid>
    <%@ Register TagPrefix="SplendidCRM" Tagname="CheckAll" Src="~/_controls/CheckAll.ascx" %>
	<SplendidCRM:CheckAll ID="ctlCheckAll" Visible="true" Runat="Server"/>

    <!--Set team to assign tasks-->
    
    <script type="text/javascript">
        function SaveCheckedTeamValue() {
            var result = [];
            $('[type="CheckedTeamItem"]').each(function () {
                var id = $(this).attr("col");
                result.push(id);
            });
            $('#<%=cltHiddenCheckedTeamValue.ClientID %>').val(result.join(","));
        }
    </script>
    <asp:UpdatePanel ID="cltFilterUpdatePanel" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <asp:HiddenField ID="cltHiddenCheckedTeamValue" runat="server" />
        <table border="0">
            <tr>
                <td>
                    <asp:ListBox runat="server" EnableViewState="true" ID="cltSearchTeamList" Width="150px" Height="200px"></asp:ListBox>
                </td>
                <td>
                    <asp:Button ID="cltAddTeam" Text=">>" runat="server" OnClick="cltAddTeam_OnClick" OnClientClick="SaveCheckedTeamValue();" />
                </td>
                <td>
                    <asp:Repeater runat="server" ID="cltCheckedTeamRepeater" EnableViewState="true" OnItemCommand="cltCheckedTeamRepeater_OnItemCommand">
                    <ItemTemplate>
                        <div type="CheckedTeamItem" col='<%#Eval("ID") %>'>
                            <asp:Label runat="server" Text='<%#Eval("NAME") %>' Width="150px" />
                            <asp:Button runat="server" CssClass="button" Text="Remove" CommandName="RemoveColumn" CommandArgument='<%#Eval("ID") %>' OnClientClick="SaveCheckedTeamValue();" />
                            <asp:Button runat="server" CssClass="button" Text="Up" CommandName="PriorityUp" CommandArgument='<%#Eval("ID") %>' OnClientClick="SaveCheckedTeamValue();" />
                            <asp:Button runat="server" CssClass="button" Text="Down" CommandName="PriorityDown" CommandArgument='<%#Eval("ID") %>' OnClientClick="SaveCheckedTeamValue();" />

                        </div>
                    </ItemTemplate>
                    </asp:Repeater>
                </td>
            </tr>
        </table>
    </ContentTemplate>
    </asp:UpdatePanel>

    <asp:Label runat="server" Text="Assign type:" Font-Bold="true" />
    <asp:RadioButtonList runat="server" ID="ctlAssignType" EnableViewState="true">
        <asp:ListItem Text="Split equal (contact order by name & team order by priority)" Value="1" Selected="True" />
        <asp:ListItem Text="Split equal (order by random)" Value="2" />
    </asp:RadioButtonList>

    <asp:Button ID="cltAssignButton" CssClass="button" runat="server" Text="Assign" OnClientClick="SaveCheckedTeamValue();" OnClick="cltAssignButton_OnClick" />



	<div id="divDetailSubPanel">
		<asp:PlaceHolder ID="plcSubPanel" Runat="server" />
	</div>
</div>

<%@ Register TagPrefix="SplendidCRM" Tagname="DumpSQL" Src="~/_controls/DumpSQL.ascx" %>
<SplendidCRM:DumpSQL ID="ctlDumpSQL" Visible="<%# !PrintView %>" Runat="Server" />


